package org.geoserver.jtilecache.service;

import java.io.IOException;
import java.io.InputStream;
import java.net.URLConnection;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.geoserver.jtilecache.mime.MimeType;

public class Response {

	private static Log log = LogFactory.getLog(org.geoserver.jtilecache.service.Response.class);

	private URLConnection connection = null;

	public Response(URLConnection connection) {
		this.connection = connection;
	}

	public MimeType getMimetype() {
		MimeType mime;
		try {
			mime = new MimeType(this.connection.getContentType(), this.connection.getContentEncoding());
		} catch(IOException ioe) {
			log.error("Mime type error: ", ioe);
			mime = new MimeType();
			mime.setToDefault();
		}
		return mime;
	}

	public InputStream getInputStream() throws IOException {
		return this.connection.getInputStream();
	}

}
